﻿package mortal.game.resource.tableConfig
{
    import Message.DB.Tables.*;
    import __AS3__.vec.*;
    import com.gengine.resource.*;
    import flash.utils.*;
    import mortal.game.resource.info.*;
    import mortal.game.view.common.*;
    import mortal.game.view.skill.*;

    public class GuildGodTreeConfig extends Object
    {
        private var _dic:Dictionary;
        private static var _instance:GuildGodTreeConfig;

        public function GuildGodTreeConfig()
        {
            if (_instance != null)
            {
                throw new Error(" GuildGodTreeConfig 单例 ");
            }
            this.init();
            return;
        }// end function

        public function init() : void
        {
            var _loc_1:* = ConfigManager.instance.getJSONByFileName("t_guild_tree_config.json");
            this.write(_loc_1);
            return;
        }// end function

        private function write(param1:Object) : void
        {
            var _loc_2:TGuildTreeConfig = null;
            var _loc_3:Object = null;
            if (!this._dic)
            {
                this._dic = new Dictionary();
            }
            for each (_loc_3 in param1)
            {
                
                _loc_2 = new TGuildTreeConfig();
                ClassTypesUtil.copyValue(_loc_2, _loc_3);
                this._dic[_loc_2.treeLevel] = _loc_2;
            }
            return;
        }// end function

        public function getInfo(param1:int) : TGuildTreeConfig
        {
            return this._dic[param1];
        }// end function

        public function getAllBuff(param1:int) : Vector.<TreeBuff>
        {
            var _loc_8:TreeBuff = null;
            var _loc_9:TBuff = null;
            var _loc_10:TSkill = null;
            var _loc_2:* = this.getInfo(param1);
            var _loc_3:* = _loc_2.buff.split("#");
            var _loc_4:* = _loc_2.skill ? (_loc_2.skill.split("#")) : ([]);
            var _loc_5:* = new Vector.<TreeBuff>;
            var _loc_6:* = _loc_3.length;
            var _loc_7:int = 0;
            _loc_7 = 0;
            while (_loc_7 < _loc_6)
            {
                
                _loc_8 = new TreeBuff();
                _loc_9 = BuffConfig.instance.getInfoById(int(_loc_3[_loc_7]));
                _loc_8.buffId = _loc_9.buffId;
                _loc_8.name = _loc_9.name;
                _loc_8.icon = _loc_9.icon;
                _loc_8.level = _loc_9.level;
                _loc_8.treeType = 1;
                _loc_8.description = _loc_9.description;
                _loc_8.copyCode = _loc_9.copyCode;
                _loc_5.push(_loc_8);
                _loc_7++;
            }
            _loc_6 = _loc_4.length;
            _loc_7 = 0;
            while (_loc_7 < _loc_6)
            {
                
                _loc_8 = new TreeBuff();
                _loc_10 = SkillConfig.instance.getInfoById(int(_loc_4[_loc_7]));
                _loc_8.buffId = _loc_10.skillId;
                _loc_8.name = _loc_10.name;
                _loc_8.icon = _loc_10.skillIcon;
                _loc_8.level = _loc_10.skillLevel;
                _loc_8.treeType = 2;
                _loc_8.description = SkillUtil.alySkillDesc(_loc_10);
                _loc_8.copyCode = _loc_10.copyCode;
                _loc_5.push(_loc_8);
                _loc_7++;
            }
            return _loc_5;
        }// end function

        public static function get instance() : GuildGodTreeConfig
        {
            if (_instance == null)
            {
                _instance = new GuildGodTreeConfig;
            }
            return _instance;
        }// end function

    }
}
